package com.example.campus;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;

import com.campus.utils.FileUtils;

import android.app.Application;
import android.support.v4.widget.DrawerLayout;

public class App extends Application implements Thread.UncaughtExceptionHandler {

	public void onCreate()
	{
		super.onCreate();
		Thread.setDefaultUncaughtExceptionHandler(this);
		
		
	}

	@Override
	public void uncaughtException(Thread thread, Throwable ex) {
		// TODO Auto-generated method stub
		StringWriter w=new StringWriter();
		ex.printStackTrace(new PrintWriter(w));
		File f=FileUtils.getLog();
		
			try {
				new FileOutputStream(f).write(w.toString().getBytes());
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		System.exit(0);
	}
	
}
